Skip to content

test: add fuzz tests for subscriber GraphQL data marshaling#5534

Open
wingwogus wants to merge 4 commits into
litmuschaos:masterfrom
wingwogus:test/add-fuzz-tests-for-subscriber-GraphQL-data-marshaling
Open

test: add fuzz tests for subscriber GraphQL data marshaling#5534
wingwogus wants to merge 4 commits into
litmuschaos:masterfrom
wingwogus:test/add-fuzz-tests-for-subscriber-GraphQL-data-marshaling

Conversation

@wingwogus

Copy link
Copy Markdown
Contributor

Proposed changes

Fixes: #5532
This PR adds focused fuzz coverage for MarshalGQLData in chaoscenter/subscriber/pkg/graphql.

The fuzz test validates that JSON-marshalable subscriber payloads are processed without unexpected errors and that the returned GraphQL payload is safely quoted, contains no raw line terminators, and can be unquoted successfully. It also adds negative coverage for unsupported marshal inputs such as function values, NaN, and Inf.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

None.

Special notes for your reviewer

Verified locally with:

cd chaoscenter/subscriber
go test ./pkg/graphql
go test ./pkg/graphql -run=^$ -fuzz=FuzzMarshalGQLData -fuzztime=30s

Signed-off-by: 이재현 <wingwogus@naver.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds targeted Go fuzz coverage for MarshalGQLData in the subscriber GraphQL package to harden marshaling/quoting behavior across a wide range of input strings and to assert expected failures for known-unsupported JSON values.

Changes:

  • Add FuzzMarshalGQLData to fuzz JSON-marshalable subscriber payloads and validate the returned payload is safely quoted/unquotable.
  • Add a negative unit test to ensure marshal errors are returned for unsupported inputs (function values, NaN, Inf).
  • Introduce a small helper (assertValidQuotedPayload) to centralize output validation checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chaoscenter/subscriber/pkg/graphql/operations_fuzz_test.go Outdated
@PriteshKiri

Copy link
Copy Markdown
Contributor

Hey @wingwogus
Could you please check the Co-Pilot review comments?

Signed-off-by: 이재현 <wingwogus@naver.com>
@wingwogus

Copy link
Copy Markdown
Contributor Author

@PriteshKiri I checked the Copilot review comments and updated the test helper to include U+2028 and U+2029 in the raw line terminator check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add fuzz tests for subscriber GraphQL data marshaling

4 participants